<%-- 
    Document   : AddPlace
    Created on : Aug 2, 2013, 11:05:42 PM
    Author     : SQL
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/base.css">
        <link rel="stylesheet" href="css/themes/type_04.css">
        <link rel="stylesheet" href="css/themes/color_13.css">
        <title>Add a new place</title>
    </head>
    <body>
        <div id="logo">
            <h1>BUI travel</h1>
        </div>
        <hr/>
        <div class="container">
            <div id="work">
                <div id="overview" class="sixteen columns">
                    <h3>Add a place</h3>
                    <hr />
                </div>
            </div>
            <form onsubmit="return preSubmit()" action="AddPlace" method="post" enctype="multipart/form-data">
                <table border="0">
                    <tbody>
                        <tr>
                            <td>Name *</td>
                            <td><input type="text" name="txtName" id="txtName" value="" style="margin-top:10px; margin-bottom:-10px; margin-left:10px "/></td>
                        </tr>
                        <tr>
                            <td>Description</td>
                            <td>
                                <textarea name="txtDescription" rows="4" cols="20" id="txtDescription" style="margin-top:10px; margin-bottom:-10px; margin-left:10px"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td>Address *</td>
                            <td><input type="text" name="txtAddress" id="txtAddress" value="" style="margin-top:10px; margin-bottom:-10px; margin-left:10px "/></td>
                        </tr>
                        <tr>
                            <td>Phone *</td>
                            <td><input type="text" name="txtPhone" id="txtPhone" value="" style="margin-top:10px; margin-bottom:-10px; margin-left:10px;" onkeypress="if ( isNaN( String.fromCharCode(event.keyCode) )) return false;"/></td>
                        </tr>
                        <tr>
                            <td>Picture *</td>
                            <td><input type="file" name="fileSelect" id="fileSelect" value="" accept="image/*" style="margin-top:10px; margin-bottom:-10px; margin-left:10px "/></td>
                        </tr>
                    </tbody>
                </table>
                <input type="hidden" name="province" value="${param.province}"/>
                <input type="submit" value="Add" name="btnAction"/>
            </form>
        </div>

    </body>
    <script>
        function preSubmit() {
            // Check for validation
            var prevent = "script";
            var input = document.getElementsByTagName("input");            
            var pass = true;
            for (var i = 0; i < input.length; i++) {
                if (input[i].type == "text") {
                    var text = input[i].value;
                    if ((text.indexOf(prevent) != -1) || (text.length == 0)) {
                        input[i].style.background = '#FF6F6F';
                        pass = false;
                    } else {
                        input[i].style.background = 'white';
                    }
                }
            }
            var file = document.getElementById("fileSelect");
            if (file.value == "") {
                pass = false;
                file.style.background = '#FF6F6F';
            } else {
                file.style.background = 'white';
            }
        
            // Create request object
            if (!pass) {
                return false;
            }
            
            var answer = window.confirm("Are you sure want you save this location?");
            if (!answer) {
                return false;
            }
        }
    </script>
</html>
